<template>
	<view style="box-sizing: border-box; padding: 10px 20px; background: #f0f0f0;">
		<view style="margin-bottom: 10px;" v-if="my_user_id==user_id">
			<u-button type="warning" shape="circle" @click="show=true">点击上传</u-button>
		</view>
		<view style="text-align: center; line-height: 100px;" v-if="images.length==0">
			暂无相册
		</view>
		<u-time-line>
			<u-time-line-item nodeTop="2" v-for="(item,key,index) in images" :key="index">
				<!-- 此处自定义了左边内容，用一个图标替代 -->
				<!-- <template v-slot:node>
					<view class="u-node" style="background: #19be6b;">
						<u-icon name="pushpin-fill" color="#fff" :size="24"></u-icon>
					</view>
				</template> -->
				<template v-slot:content>
					<view style="background: #fff; border-radius: 8px; padding: 10px;">
						<!-- <view class="u-order-title">待取件</view> -->
						<view class="" style="display: flex;align-items: center;justify-content: space-between;">
							<view class="u-order-time">{{key}}</view>
							<!-- <view class="" style="font-size: 28rpx;color: red;">
								删除
							</view> -->
						</view>
						
						<view class="u-order-desc">
							<view
								style="width: 100%;display: flex; flex-wrap: wrap; text-align: center; overflow: hidden; border-radius: 6px;">
								<!-- <image style="width: 100%;" :src="item.photo_url" mode="widthFix"></image> -->
								<view v-for="(items,i) in item"  class="listboxlist" style="flex-wrap: wrap; overflow: hidden; border-radius: 6px; line-height: 0; box-sizing: border-box; padding: 5px;  " :style="{'width':item.length>3?'33.3%':100/item.length+'%'}">
								    <view class="" style="width: 100%;position: relative;">
								    	<image @click="previewImg(key,i)" style="width: 100%;" :src="items.file" mode="widthFix"></image>
										<image src="../../static/question-delete.png" mode="aspectFill" style="position: absolute;top: 0;right: 0;width: 40rpx;height: 40rpx;background-color: #999999;border-radius: 45rpx;" @click="delPhotoed(items)"></image>
								    </view>
									
								</view>

							</view>
						</view>

					</view>
				</template>
			</u-time-line-item>
			<!-- <u-time-line-item>
				<template v-slot:content>
					<view>
						<view class="u-order-desc">【深圳市】日照香炉生紫烟，遥看瀑布挂前川，飞流直下三千尺，疑是银河落九天。</view>
						<view class="u-order-time">2019-12-06 22:30</view>
					</view>
				</template>
			</u-time-line-item> -->
		</u-time-line>
		<u-popup v-model="show" mode="bottom">
			<view style="line-height: 50px; text-align: center;">
				请选择发布的内容
			</view>
			<view style="padding: 20px 200rpx; display: flex; text-align: center; justify-content: space-around;">
				<view @click="publish(3)" style="width: 33.3%;">
					<image src="/static/l1.png" style="width: 50px; height: 50px;"></image>
					<view>
						图片
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		myPhotos,
		delPhoto
	} from "@/common/config/request.js"
	export default {
		data() {
			return {
				show: false,
				user_id: "",
				my_user_id:"",//我的id
				images: {}
			}
		},
		onLoad(option) {
			this.user_id = option.user_id
			this.my_user_id=uni.getStorageSync('userdata').id
		},
		onShow() {
			this.getMyPhoto()
		},
		methods: {
			// 删除照片
			delPhotoed(item){
				delPhoto({id:item.id}).then(res=>{
					console.log(res)
					this.getMyPhoto()
				})
			},
			// 预览图片多张
			previewImg(item,index) {
				console.log(item)
				console.log(this.images[item])
				// return false
				var images=[]
				
				this.images[item].forEach(items=>{
					images.push(items.file)
				})
				
				uni.previewImage({
					current: index,
					urls: images,
					indicator: 'number',
					loop: true
				});
				
			},
			getMyPhoto() {
				let data = {
					user_id: this.user_id
				}
				myPhotos(data).then((res) => {
					console.log(res, '2222')
					if (res.data.code == 1) {
						console.log(res.data.data, '我的图片')
						this.images = res.data.data
					}
				})
			},
			publish(e) {
				// 3图片 4视频
				this.show = false
				uni.navigateTo({
					url: `/pages/publish/publish?type=${e}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f0f0f0;
	}

	.u-node {
		width: 44rpx;
		height: 44rpx;
		border-radius: 100rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #d0d0d0;
	}

	.u-order-title {
		color: #333333;
		font-weight: bold;
		font-size: 32rpx;
	}

	.u-order-desc {
		color: rgb(150, 150, 150);
		font-size: 28rpx;
		margin-bottom: 6rpx;
	}

	.u-order-time {
		color: rgb(200, 200, 200);
		font-size: 26rpx;
	}
</style>
